Mesa 2 ships with two sample applications to demonstrate how Mesa deals with real-time data feeds. The first, feed.exe, simulates the behavior of a real-time stock-market data feed that sends stock market information into Mesa. The second, page.exe, simulates the behavior of a pager that accepts messages from Mesa.
USING FEED:
To start Feed:
o from the C: prompt, type "feed -t"
o from the Icon View, double-click the feed.exe icon.
The Parameters field in the object setting must contain "-t".
If feed.exe isn't working properly when launched by
double-clicking the icon, open the Settings panel
for it and enter "-t" in the Parameters field.
When Feed starts running, it will generate simulated stock bids in the following format:
BID <stockname> <price>
...and will attempt to send those stock bids to Mesa.
If Mesa is not running, Feed will return a "Failed" message with each failed attempt to transfer data into Mesa.
If Mesa and Feed are both running, Mesa will incorporate Feed's output into an internal "feed table." (Any other real-time feeds you write will also be incorporated into this table.) This feed table can be used by the FEED() function to retrieve a current price, given the stockname and "BID".
For example, the formula:
=FEED("BID", "Athena")
will look for an entry in the feed table of the form
BID Athena <price>
...and will return <price>, or a !RTF error if no such entry is found.
Note that Mesa will accept real-time input and build a data table, even if there is no workbook open that refers to the data table. Therefore, if you are not using the FEED() function anywhere visible, the operation of Feed will not have any noticable effect.
USING PAGE:
To start Page:
o from the C: prompt, type "page"
o from the Icon View, double-click the page.exe icon.
When Page starts running, it will open a display panel and periodically check Mesa for real-time output of the form:
Page <string>
If Page finds this output, it displays <string> in the display panel.
If Mesa is not running, or is not generating output, Page sits there patiently and waits.
A Mesa workbook can be made to generate output with the SIGNAL() function. For example, the formula:
=SIGNAL(1, "Page", "Call your sister!")
...generates the following output:
Page Call your sister!
If Page is running, it will then display "Call your sister!" in the display panel.
If there is no SIGNAL function operating, Page will not do anything special.
USING PORTLFIO.M2:
Portflio.m2 is a workbook we have built to demonstrate the FEED() and SIGNAL() functions described above. The "Bid" column contains FEED() formulas that look at the feed table to determine the current bid price for different stocks. The bid price is compared to pre-set price paramenters.
If the bid price drops lower than the pre-set "Buy" parameter, the workbook sends a "Buy <stock>" signal which Page displays. If the bid price exceeds the pre-set "Sell" parameter, the workbook sends a "Sell <stock>" signal which Page displays. If the bid price is between the "Buy" and "Sell" paremeters, nothing particularly interesting happens.